home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopete / kopetesimplemessagehandler.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.0 KB  |  91 lines

  1. /*
  2.     kopetesimplemessagehandler.h - Kopete Message Filtering - simple interface
  3.  
  4.     Copyright (c) 2004      by Richard Smith         <kde@metafoo.co.uk>
  5.     Kopete    (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
  6.  
  7.     *************************************************************************
  8.     *                                                                       *
  9.     * This library is free software; you can redistribute it and/or         *
  10.     * modify it under the terms of the GNU Lesser General Public            *
  11.     * License as published by the Free Software Foundation; either          *
  12.     * version 2 of the License, or (at your option) any later version.      *
  13.     *                                                                       *
  14.     *************************************************************************
  15. */
  16.  
  17. #ifndef KOPETESIMPLEMESSAGEHANDLER_H
  18. #define KOPETESIMPLEMESSAGEHANDLER_H
  19.  
  20. #include "kopete_export.h"
  21. #include "kopetemessagehandler.h"
  22.  
  23. namespace Kopete
  24. {
  25.  
  26. /**
  27.  * @brief A MessageHandlerFactory that creates synchronous MessageHandlers that just call a slot
  28.  *
  29.  * A concrete MessageHandlerFactory. This class is intended to make writing MessageHandlers simpler;
  30.  * all that is required is to implement a message processing function and place an instance of this
  31.  * class in your Plugin-derived class.
  32.  *
  33.  * Whenever a message passes through a handler created by this factory, the slot passed to the
  34.  * constructor will be called. The slot should take a single argument of type (non-@p const)
  35.  * <tt>Message &</tt>.
  36.  */
  37. class KOPETE_EXPORT SimpleMessageHandlerFactory : public MessageHandlerFactory
  38. {
  39. public:
  40.     /**
  41.      * @param direction The direction this factory should create message handlers for
  42.      * @param position Where in the chain the handler should be installed
  43.      * @param target The object to call back to when handling a message
  44.      * @param slot The slot on @p target to call when handling a message
  45.      * @see Kopete::MessageHandlerFactory::filterPosition
  46.      */
  47.     SimpleMessageHandlerFactory( Message::MessageDirection direction, int position,
  48.                                  QObject *target, const char *slot );
  49.     ~SimpleMessageHandlerFactory();
  50.     
  51.     /**
  52.      * Creates and returns a SimpleMessageHandler object.
  53.      */
  54.     MessageHandler *create( ChatSession *manager, Message::MessageDirection direction );
  55.     /**
  56.      * Returns the filter position passed to the constructor if @p direction matches the
  57.      * direction passed to the constructor, otherwise returns @c StageDoNotCreate.
  58.      */
  59.     int filterPosition( ChatSession *manager, Message::MessageDirection direction );
  60.     
  61. private:
  62.     class Private;
  63.     Private *d;
  64. };
  65.  
  66. /**
  67.  * @internal This class is used to implement SimpleMessageHandlerFactory.
  68.  */
  69. class SimpleMessageHandler : public MessageHandler
  70. {
  71.     Q_OBJECT
  72. public:
  73.     SimpleMessageHandler();
  74.     ~SimpleMessageHandler();
  75.     
  76.     void handleMessage( MessageEvent *event );
  77.     
  78. signals:
  79.     void handle( Kopete::Message &message );
  80.     
  81. private:
  82.     class Private;
  83.     Private *d;
  84. };
  85.  
  86. }
  87.  
  88. #endif
  89.  
  90. // vim: set noet ts=4 sts=4 sw=4:
  91.